package com.googlecode.likesql;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import com.googlecode.likesql.context.SerialSqlContext;

/**
 * The SerialLikeSql class represents a LikeSql which can be serial modified.
 * 
 * @author Johny Huang
 *
 */
public abstract class SeriallLikeSql implements LikeSql{

	/**
	 * A context contains all the SQL template and values.
	 */
	protected SerialSqlContext context;
	
	/**
	 * Constucts a SerialLikeSql instance with a {@link com.googlecode.likesql.context.SerialSqlContext SerialSqlContext}.
	 * 
	 * @param context
	 */
	public SeriallLikeSql(SerialSqlContext context){
		this.context=context;
	}
	
	/* (non-Javadoc)
	 * @see com.googlecode.likesql.LikeSql#toTemplate()
	 */
	public String toTemplate() {
		return context.getTemplate();
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString(){
		return context.getSql();
	}
	
	/* (non-Javadoc)
	 * @see com.googlecode.likesql.LikeSql#getValueList()
	 */
	public List getValueList(){
		return context.getValueList();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.likesql.LikeSql#toPreStatement(java.sql.Connection)
	 */
	public PreparedStatement toPreStatement(Connection con) throws SQLException {
		return context.getPreStatement(con);
	}
}
